# coding=utf-8

"""
    Created by Kalyter on 2017-11-25.
"""
import matplotlib.pyplot as plt
from matplotlib import cm
import matplotlib

matplotlib.rcsetup.interactive_bk # 获取 interactive backend
matplotlib.rcsetup.non_interactive_bk # 获取 non-interactive backend
matplotlib.rcsetup.all_backends # 获取 所有 backend
matplotlib.rcParams['font.sans-serif'] = ['SimHei']
matplotlib.rcParams['font.family'] = 'sans-serif'
# 解决负号'-'显示为方块的问题
matplotlib.rcParams['axes.unicode_minus'] = False


def simple_heat_map(data, x_labels, y_labels):
    colors = ['#FFFFFF', '#000000']
    cmap = cm.colors.LinearSegmentedColormap.from_list('cmap', colors)
    figure = plt.figure(figsize=(20, 20), facecolor='w')
    ax = figure.add_subplot(111, position=[0.05, 0.4, 0.55, 0.55])
    font_dict = {'fontsize': 20, 'weight': 'bold'}
    zoom = 1
    ax.set_yticks(range(0, len(y_labels) * zoom, zoom))
    ax.set_yticklabels(y_labels, font_dict)
    ax.set_xticks(range(0, len(x_labels) * zoom, zoom))
    ax.yaxis.tick_right()
    x_font_dict = font_dict.copy()
    x_font_dict.update({'rotation': 90})
    ax.set_xticklabels(x_labels, x_font_dict)

    vmax = data[0][0]
    vmin = data[0][0]
    for i in data:
        for j in i:
            if j > vmax:
                vmax = j
            if j < vmin:
                vmin = j
    map = ax.imshow(data, cmap=cmap, shape=(0.1, 0.2))
    # plt.colorbar(mappable=map)
    plt.show()
